﻿using System.Collections;
using System.Collections.Generic;
using UBlockly.Scriptable;
using UnityEngine;
using UnityEngine.EventSystems;

namespace UBlockly.Compotent
{
    [RequireComponent(typeof(UInputField))]
    internal class IntRGetterCompotent : IParamGetterCompotent
    {
        [SerializeField]
        UInputField uInput;

        void Awake()
        {
            uInput = GetComponent<UInputField>();
            uInput.contentType = UnityEngine.UI.InputField.ContentType.IntegerNumber;
        }
        public override System.Type ValueType => typeof(IntR); 

        protected override object InputGetter()
        {
            if (string.IsNullOrEmpty(uInput.text))
                return 0;
            return int.Parse(uInput.text);
        }
        protected override void OnParamSelected(BaseEventData eventData)
        {
            //默认的输入
            return;
        }

        protected override void OnParamDeselected(BaseEventData eventData)
        {
            return;
        }

        public override void SetDisplayValue(string display)
        {
            uInput.text = display;
        }
    }
}
